<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../assets/ico/favicon.ico">

<title>My Car Shopee</title>
<%@ include file="/templates/commonHeader.jsp"%>
</head>

<body>
	<%
		pageContext.setAttribute("hideError", "hide",
				PageContext.PAGE_SCOPE);

		if (request.getAttribute("errorMessage") != null)

		{
			pageContext.setAttribute("hideError", "show",
					PageContext.PAGE_SCOPE);
		}
	%>


	<%@ include file="/templates/commonMenu.jsp"%>

	<div id="wrap">

		<div class="container clear-top">

			<div class="jumbotron">
				<div class="alert alert-danger ${pageScope.hideError}">${requestScope.errorMessage}</div>
				<form class="form-inline" role="form" method="post" action="search">
					<div class="row">
						<div class="col-lg-4">
							<div class="input-group ">
								<span class="input-group-addon">$</span> <input type="text"
									name="lowerAmount" class="form-control number" id="lowerAmount"
									placeholder="Lower Dollar Amount"> <span
									class="input-group-addon">.00</span>
							</div>
						</div>
						<div class="col-lg-5">
							<div class="input-group span3">
								<span class="input-group-addon">$</span> <input type="text"
									name="upperAmount" class="form-control number" id="upperAmount"
									placeholder="Maximum Dollar Amount"> <span
									class="input-group-addon">.00</span>
							</div>
						</div>

						<div class="col-lg-3">


							<input type="submit" class="btn  btn-success" value="Search">
						</div>
					</div>
				</form>



			</div>


			<div>


				<c:choose>
					<c:when test="${ not (empty (requestScope.productsList)) }">

						<table class="table table-striped table-bordered table-hover">
							<thead style="background-color: #D8D8D8;">
								<tr>
									<td><h4>Product Name</h4></td>
									<td><h4>Product Vendor</h4></td>
									<td><h4>Market Price</h4></td>
									<td><h4>Our Price</h4></td>
									<td><h4>Product Type</h4></td>
									<td><h4>Image</h4></td>
									<td><h4>Action</h4></td>
								</tr>
							</thead>

							<tbody>

								<c:forEach items="${requestScope.productsList}" var="car">
									<tr>
										<td><strong> ${car.productName } </strong></td>
										<td><strong>${car.productVendor }</strong></td>
										<td><strong> ${car.MSRP} </strong></td>
										<c:choose>
											<c:when test="${(car.MSRP - car.buyPrice)>=25 }">
												<td style="background-color: #FFEEDD;"><strong>
														${car.buyPrice } </strong></td>

											</c:when>
											<c:otherwise>

												<td><strong> ${car.buyPrice } </strong></td>

											</c:otherwise>
										</c:choose>
										<td><strong> ${car.productLine} </strong></td>
										<td><strong> NOT AVAILABLE </strong></td>
										<td><strong> <a href="buy?"
												class="btn btn-success btn-sm"> BUY </a> <a href="moreInfo?"
												class="btn btn-default btn-sm"> Details </a></strong></td>
									</tr>
								</c:forEach>
							</tbody>

						</table>

					</c:when>

					<c:otherwise>
						<div class="alert alert-error">
							<h2>
								There is No Products match your Search Criteria at this point ,
								<a href="search.jsp"> Please refine your search above.</a>
							</h2>

						</div>

					</c:otherwise>
				</c:choose>

			</div>


		</div>
		<%@ include file="/templates/commonFooter.jsp"%>

	</div>



	<!-- Bootstrap core JavaScript
    ================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->
	<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
	<!-- Latest compiled and minified JavaScript -->
	<script
		src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
</body>
</html>